﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Web.UI.HtmlControls;

namespace NJL.Web
{
    public partial class LocalColorNews : BasePageVisitor
    {
        private readonly BLL.NJL_SYS_NEWS bllSystemNews = new BLL.NJL_SYS_NEWS();
        private readonly BLL.NJL_USER bllUser = new BLL.NJL_USER();
        private readonly BLL.NJL_PERSON bllPerson = new BLL.NJL_PERSON();
        private readonly BLL.NJL_COMPANY bllCompany = new BLL.NJL_COMPANY();
        private readonly BLL.NJL_LOCAL_COLOR_NEWS bll = new BLL.NJL_LOCAL_COLOR_NEWS();
        private readonly BLL.NJL_LOCAL_COLOR bllLocalColor = new BLL.NJL_LOCAL_COLOR();

        protected Model.NJL_LOCAL_COLOR_NEWS model;
        protected Model.NJL_LOCAL_COLOR modelLocalColor;
        protected Model.NJL_USER modelUser = new Model.NJL_USER();
        protected Model.NJL_PERSON modelPerson;
        protected Model.NJL_COMPANY modelCompany;
        protected IList<Model.NJL_LOCAL_COLOR_NEWS> LIST_SYS_NEWS;
        protected void Page_Load(object sender, EventArgs e)
        {
            model = bll.GetModel(Request.QueryString["id"]);          
            modelLocalColor = bllLocalColor.GetModel(model.NJL_LOCAL_COLOR_ID);
            LIST_SYS_NEWS = bll.GetModelList(10, "NJL_LOCAL_COLOR_ID='" + modelLocalColor.ID + "'", "SORT desc,CREATE_DATE_TIME DESC");
            if (!IsPostBack)
            {
                LoadData();
                LoadPageSEO();
            }

        }
        /// <summary>
        /// 加载页面SEO
        /// </summary>
        private void LoadPageSEO()
        {
            if (model.SEO_TITLE != null)
            {
                Page.Title = model.SEO_TITLE;
            }
            else
            {
                Page.Title = model.NEWS_TITLE;
            }
            HtmlMeta myMeta = new HtmlMeta();
            myMeta.Name = "Keywords";
            myMeta.Content = model.SEO_KEYWORDS;
            this.Header.Controls.Add(myMeta);
            HtmlMeta myMeta1 = new HtmlMeta();
            myMeta1.Name = "Description";
            myMeta1.Content = model.SEO_DESCRIPTION;
            this.Header.Controls.Add(myMeta1);
        }
        private void LoadData()
        {
            if (Request.QueryString["id"] != null && Request.QueryString["id"] != "")
            {
                if (model == null)
                {
                    Response.Redirect("/Default.aspx", true);
                }
                DataSet ds = bllLocalColor.GetList(5, "TYPE_CODE='" + modelLocalColor.TYPE_CODE + "' and NJL_SYS_BASE_ID='" + WEBSITE_CODE + "' and AREA_CODE='" + WEBSITE_FOCUS_CITY_CODE + "' and ID!='" + modelLocalColor.ID + "'", "SORT desc,VISIT_COUNT desc,CREATE_DATE_TIME desc");
                rptdfts.DataSource = ds;
                rptdfts.DataBind();
                litTitle.Text = modelLocalColor.NEWS_TITLE;
            }
            else
            {
                Response.Redirect("/Default.aspx", true);
            }
        }

    }
}